package cn.tide.question2.question;

import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 第7题对接redis读写数据
 */
public class question7 {
    public static void main(String[] args) {

        Jedis jedis = new Jedis("localhost");
        jedis.set("k1","Stringv1");
        String v1 = jedis.get("k1");
        System.out.println("string:"+v1);

        jedis.hset("myhash","name","wang");
        jedis.hset("myhash","age","19");
        Map<String, String> myhash = jedis.hgetAll("myhash");
        System.out.println("hash:"+myhash);

        jedis.lpush("mylist","list11");
        List<String> mylist = jedis.lrange("mylist", 0, -1);
        System.out.println("list:"+mylist);

        jedis.sadd("myset","settest0");
        Set<String> myset = jedis.smembers("myset");
        System.out.println("set:"+myset);

        jedis.zadd("mysort",70,"wang");
        jedis.zadd("mysort",60,"zhang");
        Set<String> mysort = jedis.zrange("mysort", 0, -1);
        System.out.println("sorted set:"+mysort);

    }
}
